/*
 * @(#)MaintWorkflowGroupForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.workflow.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.workflow.bean.WorkflowGroup;

/**
  MaintWorkflowGroupForm.java

  This class is the for web form purpose.

  @author          Angus Shiu
  @company         DCIVision Limited
  @creation date   29/07/2003
  @version         $Revision: 1.4 $
*/

public class MaintWorkflowGroupForm extends com.dcivision.setup.web.AbstractActionPermissionForm {

  public static final String REVISION = "$Revision: 1.4 $";

  private String groupName = null;
  private String description = null;

  public MaintWorkflowGroupForm() {
    super();
  }

  public String getGroupName() {
    return(this.groupName);
  }

  public void setGroupName(String groupName) {
    this.groupName = groupName;
  }

  public String getDescription() {
    return(this.description);
  }

  public void setDescription(String description) {
    this.description = description;
  }
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setGroupName(null);
    this.setDescription(null);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    WorkflowGroup tmpWorkflowGroup = new WorkflowGroup();
    tmpWorkflowGroup.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpWorkflowGroup.setGroupName(this.getGroupName());
    tmpWorkflowGroup.setDescription(this.getDescription());
    tmpWorkflowGroup.setRecordStatus(this.getRecordStatus());
    tmpWorkflowGroup.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpWorkflowGroup.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpWorkflowGroup.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpWorkflowGroup.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpWorkflowGroup.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpWorkflowGroup;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    WorkflowGroup tmpWorkflowGroup = (WorkflowGroup)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpWorkflowGroup.getID()));
    this.setGroupName(tmpWorkflowGroup.getGroupName());
    this.setDescription(tmpWorkflowGroup.getDescription());
    this.setRecordStatus(tmpWorkflowGroup.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpWorkflowGroup.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpWorkflowGroup.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpWorkflowGroup.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpWorkflowGroup.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpWorkflowGroup.getUpdateDate()));
  }
}
